//
//  macro.h
//  cyjf
//
//  Created by tauCross on 2017/4/17.
//  Copyright © 2017年 Auto Financing. All rights reserved.
//

#ifndef macro_h
#define macro_h



#pragma mark - Log

#ifdef DEBUG
#define DLog(fmt, ...) printf("%s\n", [[NSString stringWithFormat:(@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__] UTF8String]);
#else
#define DLog(...)
#endif



#pragma mark - UI

#define CYImage(name) [UIImage imageNamed:name]

#define SCREEN_HEIGHT           ([UIScreen mainScreen].bounds.size.height)
#define SCREEN_WIDTH            ([UIScreen mainScreen].bounds.size.width)
#define SCREEN_SCALE            ([UIScreen mainScreen].scale)
#define SAFE_TOP_HEIGHT         (SCREEN_HEIGHT == 812.0 ? 88 : 64)
#define SAFE_BOTTOM_HEIGHT         (SCREEN_HEIGHT == 812.0 ? 82 : 49)

#define APP_DEFAULT_COLOR_RED   HEXCOLOR(@"E94545")
#define APP_DEFAULT_COLOR_BLUE  HEXCOLOR(@"3E8CE6")

#define APP_LOCK_USER_INTERACTION   [[UIApplication sharedApplication] keyWindow].userInteractionEnabled = NO;
#define APP_UNLOCK_USER_INTERACTION [[UIApplication sharedApplication] keyWindow].userInteractionEnabled = YES;

#define APP_SQUARE_PLACEHOLDER      CYImage(@"public_square_placeholder")
#define APP_RECTANGLE_PLACEHOLDER   CYImage(@"public_rectangle_placeholder")



#pragma mark - System

#define CY_MainBundle_InfoDictionaryValue(infoKey)                  [[[NSBundle mainBundle] infoDictionary] valueForKey:infoKey]
#define CYAppVersion                                                CY_MainBundle_InfoDictionaryValue(@"CFBundleShortVersionString")
#define CYAppBuild                                                  CY_MainBundle_InfoDictionaryValue(@"CFBundleVersion")
#define CYBundleIdentifier                                          CY_MainBundle_InfoDictionaryValue(@"CFBundleIdentifier")

#define IOS10_OR_LATER              ([[UIDevice currentDevice].systemVersion compare:@"10" options:NSNumericSearch] != NSOrderedAscending)



#pragma mark - Operation

#define CY_YEAR_DAY 365



#pragma mark - Safe

#define SAFE_NUMBER(macro_number)           ([macro_number isKindOfClass:[NSNumber class]] ? macro_number : @0)
#define SAFE_STRING(macro_string)           ([macro_string isKindOfClass:[NSString class]] ? macro_string : @"")


#define TCRACObserve(TARGET, KEYPATH) \
({ \
__weak id target_ = (TARGET); \
[target_ rac_valuesForKeyPath:@keypath(TARGET, KEYPATH) observer:self]; \
})


#endif /* macro_h */
